<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ include file="../include.jsp"%>
<style>
.site-block {
	padding: 20px;
	border: 1px solid #eee;
}

.site-text {
	position: relative;
}
</style>
<div class="site-block site-text">
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">班级名称</label>
			<div class="layui-input-block">
				<input type="hidden" name="classesId" value="${row.classesId }">
				<input type="text" name="name" lay-verify="required" placeholder="请输入班级名称" value="${row.name }" autocomplete="off" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">班级描述</label>
			<div class="layui-input-block">
				<textarea name="description" placeholder="请输入班级描述" class="layui-textarea">${row.description }</textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="classesModify">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary" id="reset">重置</button>
			</div>
		</div>
	</form>
</div>

<script>
	//Demo
	layui.use('form', function() {
		var form = layui.form(),
		$ = layui.jquery;
		form.render();
		//监听提交
		form.on('submit(classesModify)', function(data) {
		//	layer.msg(JSON.stringify(data.field));
			var tmpIndex = layer.load({shade: [0.8, '#393D49']});
		    $.post('${ctx}/console/classes/update',data.field,function(rst){
		    	console.debug(rst);
		    	layer.close(tmpIndex);
		    	if(!rst){
		    		layer.msg('网络连接错误，请稍后再试。。。', {
		    			icon: 2,
		    			shade: [0.8, '#393D49'],
	    			  	anim: 6
	    			});
		    		return ;
		    	}
		    	
		    	if('error' == rst.code){
		    		layer.msg(rst.message, {
		    			time:2000,
		    			icon: 2,
		    			shade: [0.8, '#393D49'],
	    			  	anim: 6
	    			});
		    		return ;
		    	}
		    	layer.confirm('修改成功,留在本页继续修改?',{icon: 3, title:'提示'}
		    	, function(index){
		    		layer.close(index);
		    	}
		    	, function(index){
		    		layer.closeAll();
		    		$('#searchBtn').trigger('click') ;
		    	});       
		    	
		    },'json');
		
			return false;
		});
	});
</script>